#include <stdio.h>
#include <stdlib.h>
#include "version.h"

__BLTIN_VAR version_var = { "version", NULL, { NULL, NULL, NULL, NULL, NULL, __version }, VAR_DEFAULT };
__BLTIN_VAR gccver_var = { "gccver", NULL, { NULL, NULL, NULL, NULL, NULL, __gccver }, VAR_DEFAULT };
__BLTIN_VAR buildtime_var = { "gccbuild", NULL, { NULL, NULL, NULL, NULL, NULL, __buildtime }, VAR_DEFAULT };
__BLTIN_VAR buildhost_var = { "buildhost", NULL, { NULL, NULL, NULL, NULL, NULL, __buildhost }, VAR_DEFAULT };
__BLTIN_VAR buildtarget_var = { "buildtarget", NULL, { NULL, NULL, NULL, NULL, NULL, __buildtarget }, VAR_DEFAULT };
__BLTIN_VAR buildfeatures_var = { "buildfeatures", NULL, { NULL, NULL, NULL, NULL, NULL, __buildfeatures }, VAR_DEFAULT };

void
__version(const struct var_reqdata *vr)
{
  set_string(vr->result, NC_VERSION_STRING);
}

void
__gccver(const struct var_reqdata *vr)
{
  add_fstring(vr->result, BUILD_STR);
  add_string(vr->result, " with ");
  add_fstring(vr->result, BUILDLIB_STR);
}

void
__buildtime(const struct var_reqdata *vr)
{
  set_string(vr->result, BUILDTIME_STR);
}

void
__buildhost(const struct var_reqdata *vr)
{
#ifdef BUILD_HOST
  set_string(vr->result, BUILD_HOST);
#else
  set_string(vr->result, "(unknown)");
#endif
}

void
__buildtarget(const struct var_reqdata *vr)
{
#ifdef BUILD_TARGET
  set_string(vr->result, BUILD_TARGET);
#else
  set_string(vr->result, "(unknown)");
#endif
}

void
__buildfeatures(const struct var_reqdata *vr)
{
#ifdef BUILTIN_FEATURES
  set_string(vr->result, BUILTIN_FEATURES);
#else
  set_string(vr->result, "(unknown)");
#endif
}

